package com.example.yiqiuser.controller;


import com.example.yiqiuser.entity.PtFavorite;
import com.example.yiqiuser.service.PtFavoriteService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ fileName:PtFavoriteController
 * @ description:
 * @ author:chen
 * @ createTime:2023/3/31 14:49
 * @ version:1.0.0
 */
@RestController
@RequestMapping("ptfavorite")
public class PtFavoriteController extends BaseController {
    @Autowired
    private PtFavoriteService ptFavoriteService;


    /**
     * 分页带参
     * @param page
     * @return
     */
    @PostMapping("page")
    public Result queryPage(@RequestBody Page<PtFavorite> page){
        Result success = success(ptFavoriteService.queryByParam(page));
        System.out.println(success);
        return success;
    }

    /**添加
     *
     * @param ptFavorite
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody PtFavorite ptFavorite){
        return success(ptFavoriteService.add(ptFavorite));
    }

    /**
     * 更新
     * @param ptFavorite
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody PtFavorite ptFavorite){
        return success(ptFavoriteService.update(ptFavorite));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable Integer id){
        return success(ptFavoriteService.deleteById(id));
    }

    /**
     * 删除
     * @param
     * @return
     */
    @DeleteMapping("deleteByObjid")
    public Result deleteByObjid(String objid){
        /*System.out.println("-------------------deleteByObjid  "+objid);*/
        return success(ptFavoriteService.deleteByObjid(objid));
    }
}
